package com.tool.toollibrary.base;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.bumptech.glide.Glide;
import com.lzy.okgo.OkGo;
import com.tool.mylibrary.utils.ActivityCollector;

import butterknife.ButterKnife;

public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener, UIInterface {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        ActivityCollector.addActivity(this);
        //得到布局文件
        setContentView(getLayoutId());
        ButterKnife.bind(this);
        //初始化View
        initView();
        //初始化界面数据
        initData();
        //绑定监听器与适配器
        initListener();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityCollector.removeActivity(this);
        //取消tag的请求
        OkGo.getInstance().cancelTag(this);
        //取消glide的请求
        Glide.with(getApplicationContext()).pauseRequests();
    }

    @Override
    public void onClick(View v) {
        processClick(v);
    }



}
